package com.example.shop.common.dto.sms;

import com.example.shop.common.bo.sms.template.SMSTemplateGenerator;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * 短信
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class ShortMessage {
    //接受的短信的手机号
    private String acceptPhoneNumber;
    //短信签名名称
    private String signName;
    //短信模板CODE
    private String templateCode;
    //templateParam用于填充templateCode模板里的${变量名}数据
    //templateParam是json格式
    private String templateParam;
    //外部流水扩展字段
    private String outId;

    public ShortMessage(String acceptPhoneNumber,String signName,String templateCode,
                        SMSTemplateGenerator generator,String outId){
        this.acceptPhoneNumber = acceptPhoneNumber;
        this.signName = signName;
        this.templateCode = templateCode;
        this.templateParam = generator.generateTemplateParam();
        this.outId = outId;
    }
    public ShortMessage setTemplateParam(SMSTemplateGenerator generator){
        templateParam = generator.generateTemplateParam();
        return this;
    }

    @Override
    public String toString() {
        return "ShortMessage{" +
                "acceptPhoneNumber='" + acceptPhoneNumber + '\'' +
                ", signName='" + signName + '\'' +
                ", templateCode='" + templateCode + '\'' +
                ", templateParam='" + templateParam + '\'' +
                ", outId='" + outId + '\'' +
                '}';
    }
}